strana 236
----------
<Grid x:Name="LayoutRoot" Background="White">
  <Grid.ColumnDefinitions>
    <ColumnDefinition Width="*" />
    <ColumnDefinition Width="*" />
  </Grid.ColumnDefinitions>

  <Grid.RowDefinitions>
    <RowDefinition Height="*" />
    <RowDefinition Height="Auto" />
    <RowDefinition Height="Auto" />
  </Grid.RowDefinitions>

  <MediaElement x:Name="media" Source="wildlife.wmv" 
    Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" />

  <Button Click="PlayMedia" Grid.Column="0" 
    Grid.Row="1" Content="Play" />
  <Button Click="PauseMedia"  Grid.Column="1" 
    Grid.Row="1" Content="Pause" />
  <Button Click="StopMedia" Grid.Column="2" 
    Grid.Row="1" Content="Stop" />

</Grid>



C#:
private void PlayMedia(object sender, RoutedEventArgs e)
{
  Wildlife_wmv.Play();
}

private void StopMedia(object sender, RoutedEventArgs e)
{
  Wildlife_wmv.Stop();
}

  private void PauseMedia(object sender, RoutedEventArgs e)
{
  Wildlife_wmv.Pause();
}



strana 237
----------
<Grid x:Name="LayoutRoot" Background="White">
  <Grid.RowDefinitions>
    <RowDefinition Height="*" />
    <RowDefinition Height="Auto" />
    <RowDefinition Height="Auto" />
  </Grid.RowDefinitions>

  <MediaElement x:Name="meWildlife" Grid.Row="0" Source="Wildlife.wmv" 
    CurrentStateChanged="meWildlife_CurrentStateChanged" />
  <TextBox x:Name="tbStav" Grid.Row="1" Text="S:"></TextBox>
  <TextBox x:Name="tbCas" Grid.Row="2" Text="T:"></TextBox>
</Grid>



strana 238
----------
C#:
using System.Windows.Threading;

private DispatcherTimer timer;

public MainPage()
{
  InitializeComponent();

  timer = new DispatcherTimer();
  timer.Interval = new TimeSpan(0, 0, 0, 0, 250);
  timer.Tick += new EventHandler(timer_Tick);
}

void timer_Tick(object sender, EventArgs e)
{
  showCurrentPosition();
}
private void showCurrentPosition()
{
  tbCas.Text = string.Format("{0:00}:{1:00}",
  meWildlife.Position.Minutes,
  meWildlife.Position.Seconds);
}

private void meWildlife_CurrentStateChanged(object sender, 
  RoutedEventArgs e)
{
  MediaElementState currentState = ((MediaElement)sender).CurrentState;
  tbStav.Text = currentState.ToString();
  if (currentState == MediaElementState.Paused ||
    currentState == MediaElementState.Stopped)
    timer.Stop();
  else
    timer.Start();
}




strana 238
----------

<Grid x:Name="LayoutRoot" Background="White">
  <Grid.RowDefinitions>
    <RowDefinition Height="*" />
    <RowDefinition Height="Auto" />
    <RowDefinition Height="Auto" />
  </Grid.RowDefinitions>

  <MediaElement x:Name="meWildlife" Grid.Row="0" Source="Wildlife.wmv" 
    BufferingProgressChanged="meWildlife_BufferingProgressChanged" 
    DownloadProgressChanged="meWildlife_DownloadProgressChanged" />
  <TextBox x:Name="tbBuff" Grid.Row="1" Text="B:"></TextBox>
  <TextBox x:Name="tbDownload" Grid.Row="2" Text="D:"></TextBox>
</Grid>
C#:
private void meWildlife_BufferingProgressChanged(object sender, 
  RoutedEventArgs e)
{
  double dStav = meWildlife.BufferingProgress * 100; 
  tbBuff.Text = "Buffering % " + dStav;
}

private void meWildlife_DownloadProgressChanged(object sender, 
  RoutedEventArgs e)
{
  double dStav = meWildlife.DownloadProgress * 100; 
  tbDownload.Text = "Downloading % " + dStav;
}



strana 239
----------
<MediaElement x:Name="meWildlife" Source="Wildlife.wmv">
  <MediaElement.Clip>
    <EllipseGeometry RadiusX="250" RadiusY="150" Center="250,150"/>
  </MediaElement.Clip>
</MediaElement>



strana 240
----------
<MediaElement x:Name="meWildlife" Grid.Row="0" 
  Source="Wildlife.wmv" Opacity="0" />
<TextBlock FontFamily="Verdana" FontSize="100" FontWeight="Bold" 
  TextWrapping="Wrap" Text="Wildlife"> 
  <TextBlock.Foreground> 
    <VideoBrush SourceName="meWildlife"/> 
  </TextBlock.Foreground>
</TextBlock>



strana 241
----------
<StackPanel Margin="40">
  <StackPanel Orientation="Horizontal">
    <TextBlock FontSize="12" Foreground="DarkGray">Time:</TextBlock>
    <TextBlock x:Name="timeTextBlock" FontSize="12" />
  </StackPanel>
  <StackPanel Orientation="Horizontal">
    <TextBlock FontSize="12" Foreground="DarkGray">Type:</TextBlock>
    <TextBlock x:Name="typeTextBlock" FontSize="12" />
  </StackPanel>
  <StackPanel Orientation="Horizontal">
    <TextBlock FontSize="12" Foreground="DarkGray">Value:</TextBlock>
    <TextBlock x:Name="valueTextBlock" FontSize="12" />
  </StackPanel>

  <MediaElement x:Name="meWildlife" Grid.Row="0" Source="Wildlife.wmv" 
    MarkerReached="meWildlife_MarkerReached" />
</StackPanel>
C#:
private void meWildlife_MarkerReached(object sender, 
  TimelineMarkerRoutedEventArgs e)
{
  timeTextBlock.Text = e.Marker.Time.Seconds.ToString();
  typeTextBlock.Text = e.Marker.Type.ToString();
  valueTextBlock.Text = e.Marker.Text.ToString();
}



strana 251
----------
<UserControl x:Class="SmoothPlay.MainPage"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
  xmlns:p="clr-namespace:Microsoft.SilverlightMediaFramework.Player;
  assembly=Microsoft.SilverlightMediaFramework.Player" 
  mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
  <Grid x:Name="LayoutRoot">
    <p:Player>
      <p:CoreSmoothStreamingMediaElement
        AutoPlay="True"
        SmoothStreamingSource=
        http://localhost:1891/Video/Big%20Buck%20Bunny.ism/Manifest />
    </p:Player>
  </Grid>
</UserControl>



strana 252
----------
<Grid x:Name="LayoutRoot" Background="White">
  <Border Background="LightGray"> 

    <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
      <Rectangle x:Name="WebcamCapture" Width="320" Height="240" 
        Fill="White"/>

      <Grid>
        <Grid.RowDefinitions>
          <RowDefinition />
          <RowDefinition />
          <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="1*" />
          <ColumnDefinition Width="1*" />
        </Grid.ColumnDefinitions>

        <TextBlock HorizontalAlignment="Center" Text="AUDIO" 
          Grid.Column="0" Grid.Row="0" />
        <ListBox x:Name="lbAudio" Grid.Row="1" Grid.Column="0">
          <ListBox.ItemTemplate>
            <DataTemplate>
              <TextBlock Text="{Binding FriendlyName}" />
            </DataTemplate>
          </ListBox.ItemTemplate>
        </ListBox>

        <TextBlock HorizontalAlignment="Center" Text="VIDEO" 
          Grid.Column="1" Grid.Row="0" />
        <ListBox x:Name="lbVideo" Grid.Row="1" Grid.Column="1">
          <ListBox.ItemTemplate>
            <DataTemplate>
              <TextBlock Text="{Binding FriendlyName}" />
            </DataTemplate>
          </ListBox.ItemTemplate>
        </ListBox>
      </Grid>

      <StackPanel Orientation="Horizontal" >
        <Button  x:Name="btStart" Margin="5" Content="START" 
          Height="30" Click="btStart_Click" />
        <Button  x:Name="btStop" Margin="5" Content="STOP" 
          Height="30" Click="btStop_Click" />
      </StackPanel>

    </StackPanel>
  </Border>
</Grid>


strana 253
----------
C#:
CaptureSource _captureSource;

public MainPage()
{
  InitializeComponent();
  Loaded += new RoutedEventHandler(MainPage_Loaded);
}

void MainPage_Loaded(object sender, RoutedEventArgs e)
{
  lbAudio.ItemsSource = 
    CaptureDeviceConfiguration.GetAvailableAudioCaptureDevices();
  lbVideo.ItemsSource = 
    CaptureDeviceConfiguration.GetAvailableVideoCaptureDevices();
  _captureSource = new CaptureSource();
}

private void btStart_Click(object sender, RoutedEventArgs e)
{
  if (_captureSource != null)
  {
    _captureSource.Stop(); 

    // nastavenie zdroja
    _captureSource.VideoCaptureDevice = 
       (VideoCaptureDevice)lbVideo.SelectedItem;
    _captureSource.AudioCaptureDevice = 
       (AudioCaptureDevice)lbAudio.SelectedItem;

    //vykreslenie snimaneho videa
    VideoBrush vidBrush = new VideoBrush();
    vidBrush.SetSource(_captureSource);
    WebcamCapture.Fill = vidBrush; 

    if (CaptureDeviceConfiguration.AllowedDeviceAccess || 
      CaptureDeviceConfiguration.RequestDeviceAccess())
    {
      _captureSource.Start();
    }
  }
}

private void btStop_Click(object sender, RoutedEventArgs e)
{
  if (_captureSource != null)
  {
    _captureSource.Stop();
  }
}




strana 238
----------



strana 238
----------



